package com.book.communication.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.book.common.entity.QueryRequest;
import com.book.travel.entity.Communication;
import com.book.travel.mapper.CommunicationMapper;
import com.book.travel.service.CommunicationService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * @Author: 张高赫
 * @Description:  20173954
 */

@Service
public class CommunicationServiceImpl extends ServiceImpl<CommunicationMapper, Communication> implements CommunicationService {
    @Autowired
    CommunicationMapper communicationMapper;

    @Override
    public List<Communication> communicationList(Communication communication) {
        QueryWrapper<Communication> communicationQueryWrapper = new QueryWrapper<>();
        return this.communicationMapper.selectList(communicationQueryWrapper);
    }

    @Override
    public List<Communication> communicationCount(Communication communication) {
        QueryWrapper<Communication> communicationQueryWrapper = new QueryWrapper<>();
        communicationQueryWrapper.last("order by love desc limit 5");
        return this.communicationMapper.selectList(communicationQueryWrapper);
    }


    @Override
    public void communicationAdd(Communication communication) {
        this.save(communication);
    }

    @Override
    public void communicationUpdate(Communication communication) {
        this.saveOrUpdate(communication);
    }

    @Override
    public void communicationDelete(String[] breReturn) {
        List<String> list = Arrays.asList(breReturn);
        this.removeByIds(list);
    }

    @Override
    public List<Communication> communicationApply(String[] communication) {
        List<String> list = Arrays.asList(communication);
        return (List<Communication>) this.listByIds(list);
    }
}
